package com.zjw.javase.reflect.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyInvocationHandlerImpl implements InvocationHandler {
	
	private Object target;//the object be proxyed
	
	public MyInvocationHandlerImpl(Object target) {
		this.target = target;
	}
	
	private void before(){
		System.out.println("before ..........");
	}

	private void after(){
		System.out.println("after ..........");
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		before();
		Object result = method.invoke(target, args);
		after();
		return result;
	}

}
